namespace M2B.GestionEntretiens.DAL.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class GestionEntretiens : DbMigration
    {
        public override void Up()
        {
            CreateTable(
               "dbo.Referentiels",
               c => new
               {
                   ReferentielId = c.Int(nullable: false, identity: true),
                   MotCle = c.String(),
                   Code = c.String(),
                   Valeur = c.String(),
                   Langue = c.String(),
                  
               })
               .PrimaryKey(t => t.ReferentielId);

            CreateTable(
                "dbo.Candidats",
                c => new
                    {
                        CandidatId = c.Int(nullable: false, identity: true),
                        Nom = c.String(),
                        Prenom = c.String(),
                        Statut = c.String(),
                        NCIN = c.Int(nullable: false),
                        Pays = c.String(),
                        Langue = c.String(),
                        Experience = c.Int(nullable: false),
                        Formation = c.String(),
                        Profil = c.String(),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        AdresseMail = c.String(),
                        Telephone = c.String(),
                        Adresse = c.String(),
                        Autre = c.String(),
                        Commentaire = c.String(),
                    })
                .PrimaryKey(t => t.CandidatId);
            
            CreateTable(
                "dbo.Entretiens",
                c => new
                    {
                        EntretienId = c.Int(nullable: false, identity: true),
                        Titre = c.String(),
                        DateEntretien = c.DateTime(),
                        Commentaire = c.String(),
                        IsValid = c.Boolean(nullable: false),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        Evaluation = c.Int(nullable: false),
                        Autre = c.String(),
                        Langue = c.String(),
                        Statut = c.Int(nullable: false),
                        Candidat_CandidatId = c.Int(),
                        Test_TestId = c.Int(),
                    })
                .PrimaryKey(t => t.EntretienId)
                .ForeignKey("dbo.Candidats", t => t.Candidat_CandidatId)
                .ForeignKey("dbo.Tests", t => t.Test_TestId)
                .Index(t => t.Candidat_CandidatId)
                .Index(t => t.Test_TestId);
            
            CreateTable(
                "dbo.Tests",
                c => new
                    {
                        TestId = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                        Description = c.String(),
                        Type = c.Int(nullable: false),
                        DateTest = c.DateTime(),
                        Duree = c.Int(nullable: false),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        Commentaire = c.String(),
                        Evaluation = c.Int(nullable: false),
                        Autre = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.TestId);
            
            CreateTable(
                "dbo.TestQuestions",
                c => new
                    {
                        TestQuestionId = c.Int(nullable: false, identity: true),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        Test_TestId = c.Int(),
                        Question_QuestionId = c.Int(),
                    })
                .PrimaryKey(t => t.TestQuestionId)
                .ForeignKey("dbo.Tests", t => t.Test_TestId)
                .ForeignKey("dbo.Questions", t => t.Question_QuestionId)
                .Index(t => t.Test_TestId)
                .Index(t => t.Question_QuestionId);
            
            CreateTable(
                "dbo.Questions",
                c => new
                    {
                        QuestionId = c.Int(nullable: false, identity: true),
                        ContenuQuestion = c.String(),
                        MaxReponses = c.Int(nullable: false),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        Type = c.Int(nullable: false),
                        Commentaire = c.String(),
                        Reponse = c.String(),
                        TextReponse = c.String(),
                        Evaluation = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.QuestionId);
            
            CreateTable(
                "dbo.Propositions",
                c => new
                    {
                        PropositionId = c.Int(nullable: false, identity: true),
                        ContenuProposition = c.String(),
                        IsReponse = c.Boolean(nullable: false),
                        DateCreation = c.DateTime(),
                        DateModification = c.DateTime(),
                        Statut = c.Boolean(nullable: false),
                        Question_QuestionId = c.Int(),
                    })
                .PrimaryKey(t => t.PropositionId)
                .ForeignKey("dbo.Questions", t => t.Question_QuestionId)
                .Index(t => t.Question_QuestionId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Propositions", new[] { "Question_QuestionId" });
            DropIndex("dbo.TestQuestions", new[] { "Question_QuestionId" });
            DropIndex("dbo.TestQuestions", new[] { "Test_TestId" });
            DropIndex("dbo.Entretiens", new[] { "Test_TestId" });
            DropIndex("dbo.Entretiens", new[] { "Candidat_CandidatId" });
            DropForeignKey("dbo.Propositions", "Question_QuestionId", "dbo.Questions");
            DropForeignKey("dbo.TestQuestions", "Question_QuestionId", "dbo.Questions");
            DropForeignKey("dbo.TestQuestions", "Test_TestId", "dbo.Tests");
            DropForeignKey("dbo.Entretiens", "Test_TestId", "dbo.Tests");
            DropForeignKey("dbo.Entretiens", "Candidat_CandidatId", "dbo.Candidats");
            DropTable("dbo.Propositions");
            DropTable("dbo.Questions");
            DropTable("dbo.TestQuestions");
            DropTable("dbo.Tests");
            DropTable("dbo.Entretiens");
            DropTable("dbo.Candidats");
            DropTable("dbo.Referentiels");
        }
    }
}
